﻿using Architecture.Domain;
using Architecture.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Architecture.Repository.Impl
{
    /// <summary>
    /// 用户信息仓储实现
    /// </summary>
    public class UserInfoRepository : BaseRepository<UserInfo>, IUserInfoRepository
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="context">数据库上下文</param>
        public UserInfoRepository(EFCoreContext context) : base(context)
        {

        }

        /// <summary>
        /// 新增用户信息
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <returns>返回受影响的行数</returns>
        public async Task<int> AddUserInfo(UserInfo userInfo)
        {
            return await base.AddAsync(userInfo);
        }

        /// <summary>
        /// 获取全部用户信息
        /// </summary>
        /// <returns>返回全部的用户信息</returns>
        public async Task<List<UserInfo>> GetUserInfo()
        {
            return await base.GetAllAsync();
        }

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <returns>返回受影响的行数</returns>
        public async Task<int> UpdateUserInfo(UserInfo userInfo)
        {
            return await base.UpdateAsync(userInfo);
        }

        /// <summary>
        /// 条件查询用户信息
        /// </summary>
        /// <param name="expre"></param>
        /// <returns></returns>
        public async Task<List<UserInfo>> GetUserInfoByUserName(Expression<Func<UserInfo, bool>> expre)
        {
            return await base.GetAsync(expre);
        }

    }
}
